/**
 * Created by jn-dinggao on 2017/7/19.
 */
app.factory('InfoUserRoleService',  function($http, $q, $resource, $cookieStore, serviceUtil, ACTIONS, METHODS, URL){
    var factory = {};
    var param = {};
    var userRoleUrl = URL.BASEURL + URL.USERROLEURL;
    initParam = function(){
        param = {

            "id":"",
            "userId":"",
            "roleId":"",
            "desc":""
        };
    };
    factory.getUserRole = function(userId) {

        initParam();
        param = {};
        param.userId = userId;
        return serviceUtil.excute(userRoleUrl +'getList', param, METHODS.getList);
    };

    factory.getRoleByUserId = function(userId) {

        initParam();
        return serviceUtil.excute(userRoleUrl +'getRoleByUserId/'+userId, null, METHODS.getList);
    };

    factory.addUserRole = function(userRole) {
        initParam();
        param = {};
        param.id = userRole.id;
        param.userId = userRole.userId;
        param.roleId = userRole.roleId;
        param.desc = userRole.desc;
        return serviceUtil.excute(userRoleUrl + 'add', param ,METHODS.save);
    };

    factory.deleteById = function(userRoleId) {
        initParam();
        param = {};
        return serviceUtil.excute(userRoleUrl +'delete/' + userRoleId, param ,METHODS.delete);
    };
    return factory;
});